{extend name="public:layout" /}

{block name="title"}
	<title>{:site('siteName')}-我的接单</title>
{/block}

{block name="css"}
	<link rel="stylesheet" type="text/css" href="__STATIC__/{$theme}/css/user.css">
	<link rel="stylesheet" href="__STATIC__/share/css/share.css" type="text/css" />
{/block}

{block name="content"}
	<div class="layui-main">
		<div class="user-main">
			<div class="user-left">
				{include file="public:user" /}
			</div>
			<div class="user-right">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li>
							<a href="/recharge/orders.html">挂售列表</a>
						</li>
						<li class="layui-this">
							<a href="/recharge/myOrders.html">我的接单</a>
						</li>
					</ul>
					<div class="layui-tab-content">
						<table class="table">
						    <thead>
						        <tr>
						            <th>超时时间</th>
						            <th>支付金额</th>
						            <th>用户名</th>
						            <th>联系方式</th>
						            <th>支付信息</th>
						            <th>备注</th>
						            <th>状态</th>
						            <th>操作</th>
						        </tr>
						    </thead>
						    <tbody>
								{volist name="list" id="v"}
							        <tr>
							            <td>{:date('m-d H:i:s',$v['timeout'])}</td>
							            <td>{$v['money']}</td>
							            <td>{$v['username']}</td>
							            <td>
							            	<button class="layui-btn layui-btn-mini layui-btn-normal see" data-msg="姓名：{$v.realname}<br>手机：{$v.mobile}<br>Q Q：{$v.qq}<br>微信：{$v.wechat}<br>邮箱：{$v.email}">查看</button>
							            </td>
							            <td>
							            	<button class="layui-btn layui-btn-mini layui-btn-normal see" data-msg="姓名：{$v.realname}<br>支付宝：{$v.alipay}<br>开户行：{$v.bank}<br>卡号：{$v.bank_card}">查看</button>
							            </td>
							            <td>{$v.note}</td>
							            <td>
							            	{eq name="v.status" value="1"}已接单{/eq}
							            	{eq name="v.status" value="2"}已支付{/eq}
							            	{eq name="v.status" value="3"}已完成{/eq}
							            	{eq name="v.status" value="4"}已撤销{/eq}
							            </td>
							            <td>
							            	{eq name="v.status" value="1"}
							            		<button class="layui-btn layui-btn-mini layui-btn-main pay" sell_id="{$v.id}">确认支付</button>
							            		<button class="layui-btn layui-btn-mini layui-btn-danger cancel" sell_id="{$v.id}">取消订单</button>
							            	{/eq}
							            </td>
							        </tr>
								{/volist}
						    </tbody>
						</table>
						<div class="page">
							{$list->render()}
						</div>
					</div>
				</div> 
			</div>
		</div>
	</div>
{/block}

{block name="script"}
	<script type="text/javascript">
		layui.use(['form','layer'], function(){
			var $ = layui.jquery;
			var form = layui.form();
			var layer = layui.layer;
			//取消订单
			$('.cancel').click(function() {
				var sell_id = $(this).attr('sell_id');
				var penalty = "{:config('currency')['cancelPunish']}";
				checkPwd(function(pwd){
					layer.confirm('取消订单将扣除'+penalty+'违约金，确定？', {
			            btn: ['确定', '取消'],
			            icon: 3
			        }, function(index) {
			            layer.close(index);
			            $.post('{:url("index/sell/cancelOrder")}', {id: sell_id,pwd:pwd}, function(res) {
			            	if(res.success == 1){
			            		layer.msg(res.msg, {
				                    time: 1000
				                }, function() {
				                	if(res.url){
				                		location.href = res.url.replace('\\');
				                	}else{
				                		location.reload();
				                	}
				                });
			            	}else{
			            		layer.msg(res.msg);
			            	}
			            });
			        });
				});
				return false;
			});
			//确认支付
			$('.pay').click(function(){
				var sell_id = $(this).attr('sell_id');
				checkPwd(function(pwd){
					layer.confirm('确定已经支付完成', {
			            btn: ['确定', '取消'],
			            icon: 3
			        }, function(index) {
			            layer.close(index);
			            $.post('{:url("index/sell/confirmPay")}', {id: sell_id,pwd:pwd}, function(res) {
			            	if(res.success == 1){
			            		layer.msg(res.msg, {
				                    time: 1000
				                }, function() {
				                	if(res.url){
				                		location.href = res.url.replace('\\');
				                	}else{
				                		location.reload();
				                	}
				                });
			            	}else{
			            		layer.msg(res.msg);
			            	}
			            });
			        });
				});
			});
			//查看
			$('.see').click(function() {
    			var msg = $(this).data('msg');
	    		layer.open({
	    		  	type: 1,
	    		  	shade: false,
	    		  	title: false,
	    		  	content: '<div style="background: #5FB878;padding: 15px;color: #fff;border-radius: 3px;">' + msg + '</div>'
	    		});

    		});

		});
	</script>
{/block}